@extends('layouts.app')
@section('header')
     @include('common.header')
@stop
@section('title', config('index_title').'-需求发布')
@section('footer')
     @include('common.footer')
@stop
@section('content')

<link href="/front/Content/tijiao.css" rel="stylesheet" />
<div class="banner1"></div>
<div class="xtxx">

    <div class="xtxx_top">
        <div class="xtxx_tit"><p><a href="/cart">名片宝库</a></p></div>
    </div>
<form id="form1" method="POST" action="/user/sendCart" enctype="multipart/form-data">
     {{ csrf_field() }}
    <div class="wdda input-box">

        <div class="clearfix">
            <p class="input-text">请输入名片上的邮箱和网址（用于平台检验其有效性）若无，请留空</p>
            <div class="clearfix">
                <p class="fl input-input" style="margin-right: 60px;">
                    <input id="cardmail" name="email" value="{{old('email')}}" placeholder="输入邮箱，如：info@textile-cards.com" type="text">
                </p>
                <p class="fl input-input"><input name="homepage" value="{{old('homepage')}}" placeholder="输入网址，如：www.textile-cards.com" type="text"></p>
            </div>
        </div>
        <div class="clearfix">
            <div class="fl" style="margin-right: 60px;">
                <p class="input-text"><em>*</em>请输入名片上的公司名称</p>
                <p class="input-input"><input id="company" name="company" value="{{old('company')}}" type="text" ></p>
                <p class="input-text"><em>*</em>请输入名片上的联系人</p>
                <p class="input-input"><input id="contact1" name="name" value="{{old('name')}}" type="text"></p>
                <p class="input-text"><em>*</em>请选择名片所属的一级领域</p>
                <p class="input-input">
                   <select name="catid" style="height: 50px;">
                    @if(isset($menu[12]) && !empty($menu[12]))
                        	@foreach($menu[12]['child'] as $k=>$row)
                        <option value="{{$row['id']}}">{{$row['name']}}</option>
                        @endforeach

                        @endif
                    </select>
				<p class="input-text">（非必选）请选择名片所属的其他纺织领域</p>
                <div class="checkbox">



                    @if(isset($menu[12]) && !empty($menu[12]))
                            @foreach($menu[12]['child'] as $k=>$row)
                        <label>
                      <input type="checkbox" name="catidr[]" value="{{$row['id']}}" / > {{$row['name']}}
                    </label>


                        @endforeach

                        @endif
                </div>

                </p>
            </div>
            <div class="fl">
                <p class="input-text"><em>*</em>请输入价格  <span style="color: #ff0000;padding-left: 15px">如名片上网址或邮箱有无效的，价格不等高于1元</span></p>
                <div>
                    <div class="clearfix jiajian">
                        <input class="fl jianjian-l" id="min" name="" type="button" value="-">
                        <input class="fl jianjian-c" id="text_box" value="{{old('price')}}" name="price" style="width:30px;text-align: center" type="text" value="1">
                        <input class="fr jianjian-r" id="add" name="" type="button" value="+">
                    </div>
                    <div class="jiajian-text">价格区间，0-50元</div>
                    <div class="jiajian-btn">0元代表免费发布


                    </div>
                </div>


                <p class="input-text" style="margin-top: 17px"><em>*</em>请输入名片上的职称</p>
                <p class="input-input"><input name="fname" value="{{old('fname')}}" type="text"></p>
                <p class="input-text"><em>*</em>请输入产品类别</p>
                <p class="input-input"><input id="goods" name="content" value="{{old('content')}}" type="text"></p>
            </div>
        </div>
    </div>
    <div class="title">以上填写信息须和名片保持一致，否则无法通过审核</div>
    <div class="wdda title-h2">
            <textarea name="remark" style="width: 800px;height: 200px;border: 3px solid #0093dd;    line-height: 25px;margin:0 0 0 180px;font-size:18px;" placeholder="产品说明，其他介绍【非必填】&#10;&#10;若不填写，用户只能通过公司名称搜索到该名片；填写产品或公司介绍，以及其它备注说明，让用户更快速检索到你的名片">{{old('content')}}</textarea>
            <!--<span style="display: block;font-size: 14px;">产品说明，其他介绍【非必填】,若不填写，用户只能通过公司名称搜索到该名片；填写产品或公司介绍</span>-->
    </div>
    <div class="wdda upload-img">
        <div class="input-text"><em>*</em>上传名片审核 <em>（审核通过，永久受益！）</em></div>
        <div class="clearfix upload-img-file">
            <label class="fl">
                <input id="cardFront" name="smetas[]" style="display: none;" type="file" accept="image/*">
                <img id="cardFrontImg" width="541px" height="331px" alt="" src="/front/Content/images/file1.png">
            </label>
            <label class="fr">
                <input id="cardBack" name="smetas[]" style="display: none;" type="file" accept="image/*">
                <img id="cardBackImg" width="541px" height="331px" alt="" src="/front/Content/images/file2.png">
            </label>
        </div>
        <label class="upload-img-text"><input id="agree" type="checkbox">点击“提交审核”代表您同意并遵守<em onclick="agree()">《名片发布协议》</em></label>
        <input class="submit" onclick="sub()" type="button" value="提交审核" style="margin-left:465px;">

    </div>
</form>

</div>
<script>

	$(function(){
		function setVal(v){
			if(v == 22){
					$('#wdda title-h2').attr('placeholder','一句话标题，请输入公司的采购或合作需求');

				}

		}


	})

</script>
<script type="text/javascript">
    $(function(){
        $('#cardFront').on('change',function(e){
            console.log(document.getElementById('cardFront').files[0]);
            renderImg(document.getElementById('cardFront').files[0],$('#cardFrontImg'));
        });
         $('#cardBack').on('change',function(e){
            console.log(document.getElementById('cardBack').files[0]);
            renderImg(document.getElementById('cardBack').files[0],$('#cardBackImg'));
        });


         function renderImg(file,el) {
            var reader = new FileReader();

            reader.onload=function(e) {

                imgFile = e.target.result;

                el.attr('src', imgFile);
            };

            reader.readAsDataURL(file);
        }
    })
</script>
<script>
    function sub()
    {

    	var agree = $("#agree").prop("checked");
        if( agree==false )
        {
            layer.msg('请同意.');
            return false;
        }
    	$('#form1').submit();


    	}

</script>
<script>
    $(document).ready(function () {
        //获得文本框对象
        var t = $("#text_box");
        //初始化数量为1,并失效减
        t.val(0);

        //数量增加操作
        $("#add").click(function () {

            var val = parseInt(t.val());
            val >= 50 ? t.val(50) : t.val(val+1);

        });
        //数量减少操作
        $("#min").click(function () {
            var val = parseInt(t.val());
            val < 1 ? t.val(0) : t.val(val-1);

        });



        $('#text_box').change(function(e){
            var val = parseInt(t.val());

            val >= 50 ? t.val(50) : null;
            val < 1 ? t.val(0) : null;

        })

    });
</script>
<script type="text/javascript">
$(function(){
	@if(session('status'))
		layer.msg("{{session('status')}}");
	@endif
})
function agree() {
	@php
	$content = \DB::table('categories')->where('id', 43)->value('content');
	@endphp
	layer.open({
		title: '《纺织品名片宝用户协议》',
		type: 1,
		  skin: 'layui-layer-rim', //加上边框
		  area: ['620px', '440px'], //宽高
		  content: '{!! $content  !!}'
		});
}
</script>
@endsection
